import React, { Component } from 'react'
import axios from "axios"
import RouterView from '../router/routerView' //1/
class Canima extends Component {
  state = {
    arr:[]
  }
  componentDidMount(){
    axios.get("/list").then(res=>{
      console.log(res.data);
      this.setState({
        arr:res.data.list
      })
    })
  }
  goDetail(item){
      this.props.history.push({
         pathname:"/detail",
         state:{
            obj:item
         }
      })
  }
  render() {
    let {child} = this.props  //2.
    // console.log(child)
    return (
      <div>
        {
          this.state.arr&& this.state.arr.length? this.state.arr.map((item,index)=>{
            return <div key={index} onClick={this.goDetail.bind(this,item)}>{item.title}</div>
          }):""
        }
    
      </div>
    )
  }
}

export default Canima